# Contributor: Carlo Landmeter <clandmeter@alpinelinux.org>
# Contributor: blattersturm <peachypies@protonmail.ch>
# Contributor: Antoni Aloy <aaloytorrens@gmail.com>
# Maintainer:
pkgname=mono
pkgver=6.12.0.122
pkgrel=1
pkgdesc="Free implementation of the .NET platform including runtime and compiler"
url="https://www.mono-project.com/"
# riscv64 - mono_os_mutex_init_type: pthread_mutexattr_setprotocol failed with "Function not implemented" (38)
arch="all !s390x !ppc64le !riscv64"
license="MIT"
depends="python3"
depends_dev="$pkgname=$pkgver-r$pkgrel libgdiplus-dev zlib-dev"
makedepends="$depends_dev autoconf automake cmake libtool linux-headers"
subpackages="$pkgname-dev $pkgname-doc $pkgname-lang"
source="https://download.mono-project.com/sources/mono/mono-$pkgver.tar.xz
	mono-try-catch.patch
	"

build() {
	# Based on Fedora and SUSE package.
	export CFLAGS="$CFLAGS -fno-strict-aliasing"

	# Set the minimum arch for x86 to prevent atomic linker errors.
	[ "$CARCH" = "x86" ] && export CFLAGS="$CFLAGS -march=i586 -mtune=generic"

	# Run autogen to fix supplied configure linker issues with make install.
	./autogen.sh \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--localstatedir=/var \
		--disable-rpath \
		--disable-boehm \
		--enable-parallel-mark \
		--with-mcs-docs=no \
		--without-sigaltstack
	make
}

package() {
	make -j1 DESTDIR="$pkgdir" install

	cd "$pkgdir"

	# Remove .la files.
	rm ./usr/lib/*.la

	# Remove Windows-only stuff.
	rm -r ./usr/lib/mono/*/Mono.Security.Win32*
	rm ./usr/lib/libMonoSupportW.*
}

dev() {
	default_dev
	mv "$subpkgdir"/usr/lib/libmono-native.so "$pkgdir"/usr/lib
}

sha512sums="0fbd4147498cc81e384933147eb6aa5c559d17a794a308af7ffa43dce51e0faefde24fc75e987ed804dcb161b52756944bc3611100fc0a4adcc260ca97ddaecd  mono-6.12.0.122.tar.xz
3a82d4bed31b212e23fe24647fc5b9c4788be5f4966377a3bef9f92a51d16181e77e19ca1ec4736792da6a18206986bbb54d967499e2ca7e224201cf811f91b5  mono-try-catch.patch"
